package com.bwie.interrogation.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.interrogation.domain.dto.AddAddressDTO;
import com.bwie.interrogation.domain.vo.AddressVo;
import com.bwie.interrogation.service.InterrogationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("Interrogation")
@RestController
public class InterrogationController {
    /**
     * 注入
     */
    @Autowired
    private InterrogationService service;

    /**
     * 添加地址
     * @param addAddressDTO
     * @return
     */
    @PostMapping("addAddress")
    public Result addAddress(@RequestBody AddAddressDTO addAddressDTO){
        //调用方法添加
        service.addAddress(addAddressDTO);
        //返回
        return Result.success();
    }

    /**
     * 获得患者地址列表
     * @return
     */
    @GetMapping("AddressList")
    public Result<List<AddressVo>> getAddressList(){
        //获得患者地址列表
        List<AddressVo> list = service.getAddressList();
        //返回
        return Result.success(list);
    }

    /**
     * 患者删除地址列表
     * @param id
     * @return
     */
    @DeleteMapping("delAddress/{id}")
    public Result delAddress(@PathVariable Long id){
        //患者删除地址列表
        service.delAddress(id);
        //返回
        return Result.success();
    }

    /**
     * 患者获得挂号医生的名称
     * @return
     */
    @GetMapping("getDoctorName")
    public Result<String> getDoctorName(){
        //患者获得挂号医生的名称
        String doctorName = service.getDoctorName();
        //返回
        return Result.success(doctorName);
    }
}
